package com.cq.hd.product.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.product.api.TbLabelApi;
import com.cq.hd.product.api.dto.LabelPageDto;
import com.cq.hd.product.api.dto.LabelSaveDto;
import com.cq.hd.product.api.vo.LabelPageVo;
import com.cq.hd.product.api.vo.LabelVo;
import com.cq.hd.product.service.TbLabelService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author much
 * @since 2024/05/19 16:29
 */
@RestController
public class TbLabelController implements TbLabelApi {

    @Resource
    private TbLabelService labelService;

    @Override
    public Result<Page<LabelPageVo>> pageLabel(LabelPageDto labelPageDto) {
        return ResultGenerator.success(labelService.pageLabel(labelPageDto));
    }

    @Override
    public Result<LabelVo> saveLabel(@RequestBody LabelSaveDto labelSaveDto) {
        return ResultGenerator.success(labelService.saveLabel(labelSaveDto));
    }

    @Override
    public Result<Void> deleteLabel(Long id) {
        labelService.deleteLabel(id);
        return ResultGenerator.success();
    }

    @Override
    public Result<List<LabelVo>> listRecommendLabels(Long businessId) {
        return ResultGenerator.success(labelService.listRecommendLabels(businessId));
    }

    @Override
    public Result<List<LabelVo>> searchByClient(Long businessId, String keyword) {
        return ResultGenerator.success(labelService.searchByClient(businessId, keyword));
    }
}
